class Solution {
public:
    string multiply(string num1, string num2) {
         vector<int> res(num1.size()+num2.size(),0);
        for(int i = num1.size() - 1;i >= 0;i--){
            for(int j = num2.size() - 1;j >= 0;j--){
                int num = (num1[i] - '0') * (num2[j] - '0') + res[i + j + 1];
                res[i + j + 1] = num % 10;
                res[i + j] += num / 10;
            }
        }
        string s;
        if(res[0] > 0) s.append(to_string(res[0]));
        for(int i = 1;i < res.size();i++){
            if(res[i] == 0 && s.size() == 0) continue;
            s.append(to_string(res[i]));
        }
        if(s.size() == 0) return "0";
        return s;
    }
};
